<template>
  <Card>
    <Table :columns="columns1" :data="data1"></Table>
    <div style="margin: 10px;overflow: hidden">
      <div style="float: right;">
        <Page
          :total="total"
          :current="current"
          :page-size="pageSize"
          @on-page-size-change="changePageSize"
          @on-change="changePage"
          :show-total="true"
          show-sizer
        ></Page>
      </div>
    </div>
  </Card>

</template>
<script>
  import {queryFillTableRecord } from "@/api/lky/lkyTableStorage";
  import { createFormObj, getToken } from '@/libs/util'

  import Add from './add.vue'

  export default {
    components: {
      Add
    },
    data() {
      return {
        columns1: [
          {
            title: '表名',
            key: 'file_name'
          },
          {
            title: '状态',
            key: 'staute',
            render: (h, params) => h('span', this.transferStaute(params.row.staute))
          },
          {
            title: '上传发布时间',
            key: 'update_date'
          }

        ],
        data1: [],
        total: 0,
        current: 1,
        pageSize: 10,
        isOpenAddPage: false
      }
    },
    methods: {
      transferStaute (val) {
        if (val == 1) {
          return '已提交'
        } else if (val == 2) {
          return '已通过'
        } else if (val == 3) {
          return '未通过'
        }
      },
      handleOpenPage (name) {
        // 打开页面事件(添加页,编辑页...)
        if (name === 'upload') this.isOpenAddPage = true
        else if (name === 'edit') {
          this.isOpenEditPage = true
        }
      },
      getPageList(current, pageSize) {
        queryFillTableRecord({
          uid: getToken(),
          pageNumber: current,
          pageSize: pageSize
        }).then(res => {
          console.log(res)
          this.data1 = res.list
          this.current = parseInt(res.pageNumber)
          this.pageSize = parseInt(res.pageSize)
          this.total = parseInt(res.totalRow)
        }).catch(err => {
          this.$Message.error(err);
        })
      },
      changePage (pageNumber) {
        this.getPageList(pageNumber, this.pageSize)
      },
      changePageSize (pageSize) {
        this.getPageList(this.current, pageSize)
      },
    },
    mounted() {
      this.getPageList(this.current,this.pageSize)
    }
  }
</script>
